<template>
    <div style="float:left" :class="wrapperClass">
        <NumberType @calexp="handle" @checkError="checkError"   :values="values" :valueIndex="valueIndex" :inputConfig="inputConfig"/>
        <Tooltip v-if="validateError" :content="errorMessage" theme="light">
            &nbsp;&nbsp;<Icon type="ios-alert-outline" color="#ed4014" />
        </Tooltip>
    </div>
</template>
<style lang="less" scoped>
</style>
<script>
    import ruiMixin from "../../mixin/rule-mixin";
    import TextType from './input/Text'
    import NumberType from './input/Number'
    export default {
        name: 'common-type',
        mixins: [ruiMixin],
        components:{
            'TextType':TextType,
            'NumberType':NumberType,
        },
        props: {
            atomKey:{
                type:String,
                require: true
            },
            values: {
                type: Array,
                require:true
            },
            valueNames: {
                type: Array,
                require:true
            },
            valueIndex:{
                type:Number,
                require: true
            },
            inputType:{
                type:String,
                require: true
            },
            inputConfig:{
                type:Object,
                require:true
            }
        },
        data() {
            return {
                wrapperClass:'',
                validateError:false,
                errorMessage:''
            }
        },
        computed: {
        },
        methods:{
            handle() {
                this.$emit('calexp');
            },
            checkError(validateError,messages){
                this.validateError = validateError;
                this.errorMessage = messages;
                if(validateError){
                    this.wrapperClass = 'ivu-form-item-error'
                }else{
                    this.wrapperClass ='';
                }
            }
        }
    }
</script>
